package com.cloudcentral;

import com.cloudcentral.util.RSAUtil;

import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;

/**
 * Create By Administrator
 * 2023-12-03 17:54
 */
public class Test {
  public static void main1(String[] args) throws Exception {
    String data = "{\"data\":{\"fpServerVersion\":\"1\",\"fpgaVersion\":\"1\",\"id\":1,\"name\":\"12\",\"registerTime\":\"2023-11-22 19:18:35\"},\"success\":true,\"timestamp\":1701595307990,\"type\":\"REGISTER\"}";
    String result = URLEncoder.encode(RSAUtil.privateKey().encrypt(data), StandardCharsets.UTF_8);
    System.out.println(result);
    System.out.println(RSAUtil.publicKey().decrypt(URLDecoder.decode(result, StandardCharsets.UTF_8)));
    System.out.println("---------------------------------");
    String test = "%25252Bor6QRfI74Cz0cY5782DH6mt1as3WMGdkowHil%25252BZkUAfLl%25252BOapr5Vwmx5UAYJAZapfRnFk%25252BGSwwVZXv5bsfjxVR8%25252BSFr%25252BFKMJ74KUVFnkPPZFOhJhh//Zwte7h/Mx7dS0vgabLMZYgjgEKFSNdV8QLm2J5pViX1KM0jwllLd1iHSY1Kb1FqcnEOfchsMgrFcVqXD2RJModGsbEOdksOIA92/O3s1Irk5MEWSWJ7A2LQXE8NxGsO52TUcy68zPDNCNQ/k2%25252BCaZDOdLIIl7nQdFnMKHvqL7mMiaDwxr/oGIE0EIE8g==";
    test = URLDecoder.decode(test, StandardCharsets.UTF_8);
    System.out.println(RSAUtil.privateKey().decrypt(test));
  }
}
